<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>子组件向父组件传递数据</title>
</head>
<body>
<div id="app">
    <cpn v-on:demo="eventProcess"></cpn>
</div>

<template id="cpn">
    <button v-on:click="$emit('demo', 1)">发送</button>
</template>

<script type="module">
    import {createApp, defineComponent, defineEmits} from "../../../../js/vue.esm-browser.js";

    let cpn = defineComponent({
        template: "#cpn",
        setup() {
            function btnClicked() {
                console.log("点击了按钮");

            }

            let emit = defineEmits(["demo"])

            return {
                btnClicked
            };
        }
    });

    let app = createApp({
        setup() {
            function eventProcess() {
                console.log("接收了子组件的消息");
            }
            return {eventProcess,}
        },
        components: {
            cpn,

        }
    })
    app.mount("#app")
</script>
</body>
</html>